home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-21 | 9.9 KB | 261 lines | [TEXT/CWIE] |
- UNIT FSpCompat;
-
- { Apple Macintosh Developer Technical Support }
- { }
- { FSSpec compatibility functions }
- { }
- { by Jim Luther, Apple Developer Technical Support Emeritus }
- { }
- { File: FSpCompat.p }
- { }
- { Copyright © 1992-1995 Apple Computer, Inc. }
- { All rights reserved. }
- { }
- { You may incorporate this sample code into your applications without }
- { restriction, though the sample code has been provided "AS IS" and the }
- { responsibility for its operation is 100% yours. However, what you are }
- { not permitted to do is to redistribute the source as "DSC Sample Code" }
- { after having made changes. If you're going to re-distribute the source, }
- { we require that you make it clear in the source that the code was }
- { descended from Apple Sample Code, but that you've made changes. }
-
-
- INTERFACE
-
- USES
- Files;
-
- {***************************************************************************}
-
-
- FUNCTION FSMakeFSSpecCompat (vRefNum: INTEGER;
- dirID: LONGINT;
- fileName: Str255;
- VAR spec: FSSpec): OSErr;
- { The FSMakeFSSpecCompat function fills in the fields of an FSSpec }
- { record. If the file system can't create the FSSpec, then the }
- { compatibility code creates a FSSpec that is exactly like an FSSpec }
- { except that spec.name for a file may not have the same capitalization }
- { as the file's catalog entry on the disk volume. That is because }
- { fileName is parsed to get the name instead of getting the name back }
- { from the file system. This works fine with System 6 where FSMakeSpec }
- { isn't available. }
- { }
- { vRefNum input: Volume specification. }
- { dirID input: Directory ID. }
- { fileName input: Pointer to object name, or nil when dirID specifies }
- { a directory that's the object. }
- { spec output: A file system specification to be filled in by }
- { FSMakeFSSpecCompat. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpOpenDFCompat ({CONST}VAR spec: FSSpec;
- permission: SignedByte;
- VAR refNum: INTEGER): OSErr;
- { The FSpOpenDFCompat function opens the data fork of the file specified }
- { by spec. }
- { Differences from FSpOpenDF: If FSpOpenDF isn't available, }
- { FSpOpenDFCompat uses PHBOpen because System 6 doesn't support }
- { PBHOpenDF. This means FSpOpenDFCompat could accidentally open a driver }
- { if the spec->name begins with a period. }
- { }
- { spec input: An FSSpec record specifying the file whose data }
- { fork is to be opened. }
- { permission input: A constant indicating the desired file access }
- { permissions. }
- { refNum output: A reference number of an access path to the file's }
- { data fork. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpOpenRFCompat ({CONST}VAR spec: FSSpec;
- permission: SignedByte;
- VAR refNum: INTEGER): OSErr;
- { The FSpOpenRFCompat function opens the resource fork of the file }
- { specified by spec. }
- { }
- { spec input: An FSSpec record specifying the file whose resource }
- { fork is to be opened. }
- { permission input: A constant indicating the desired file access }
- { permissions. }
- { refNum output: A reference number of an access path to the file's }
- { resource fork. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpCreateCompat ({CONST}VAR spec: FSSpec;
- creator: OSType;
- fileType: OSType;
- scriptTag: ScriptCode): OSErr;
- { The FSpCreateCompat function creates a new file with the specified }
- { type, creator, and script code. }
- { Differences from FSpCreate: FSpCreateCompat correctly sets the }
- { fdScript in the file's FXInfo record to scriptTag if the problem }
- { isn't fixed in the File Manager code. }
- { }
- { spec input: An FSSpec record specifying the file to create. }
- { creator input: The creator of the new file. }
- { fileType input The file type of the new file. }
- { scriptCode input: The code of the script system in which the file }
- { name is to be displayed. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpDirCreateCompat ({CONST}VAR spec: FSSpec;
- scriptTag: ScriptCode;
- VAR createdDirID: LONGINT): OSErr;
- { The FSpDirCreateCompat function creates a new directory and returns }
- { the directory ID of the newDirectory. }
- { }
- { spec input: An FSSpec record specifying the directory to }
- { create. }
- { scriptCode input: The code of the script system in which the }
- { directory name is to be displayed. }
- { createdDirID output: The directory ID of the directory that was }
- { created. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpDeleteCompat ({CONST}VAR spec: FSSpec): OSErr;
- { The FSpDeleteCompat function deletes a file or directory. }
- { }
- { spec input: An FSSpec record specifying the file or }
- { directory to delete. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpGetFInfoCompat ({CONST}VAR spec: FSSpec;
- VAR fndrInfo: FInfo): OSErr;
- { The FSpGetFInfoCompat function gets the finder information for a file. }
- { }
- { spec input: An FSSpec record specifying the file. }
- { fndrInfo output: If the object is a file, then its FInfo. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpSetFInfoCompat ({CONST}VAR spec: FSSpec;
- fndrInfo: FInfo): OSErr;
- { The FSpSetFInfoCompat function sets the finder information for a file. }
- { }
- { spec input: An FSSpec record specifying the file. }
- { fndrInfo input: The FInfo. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpSetFLockCompat ({CONST}VAR spec: FSSpec): OSErr;
- { The FSpSetFLockCompat function locks a file. }
- { }
- { spec input: An FSSpec record specifying the file. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpRstFLockCompat ({CONST}VAR spec: FSSpec): OSErr;
- { The FSpRstFLockCompat function unlocks a file. }
- { }
- { spec input: An FSSpec record specifying the file. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpRenameCompat ({CONST}VAR spec: FSSpec;
- newName: Str255): OSErr;
- { The FSpRenameCompat function renames a file or directory. }
- { }
- { spec input: An FSSpec record specifying the file. }
- { newName input: The new name of the file or directory. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpCatMoveCompat ({CONST}VAR source: FSSpec;
- {CONST}VAR dest: FSSpec): OSErr;
- { The FSpCatMoveCompat function moves a file or directory to a different }
- { location on on the same volume. }
- { }
- { source input: An FSSpec record specifying the file or directory. }
- { dest input: An FSSpec record specifying the name and location }
- { of the directory into which the source file or }
- { directory is to be moved. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpExchangeFilesCompat ({CONST}VAR source: FSSpec;
- {CONST}VAR dest: FSSpec): OSErr;
- { The FSpExchangeFilesCompat function swaps the data in two files by }
- { changing the information in the volume's catalog and, if the files }
- { are open, in the file control blocks. }
- { Differences from FSpExchangeFiles: Correctly exchanges files on volumes }
- { that don't support PBExchangeFiles. FSpExchangeFiles attempts to }
- { support volumes that don't support PBExchangeFiles, but in System 7, }
- { 7.0.1, 7.1, and 7 Pro, the compatibility code just doesn't work on }
- { volumes that don't support PBExchangeFiles (even though you may get a }
- { noErr result). System Update 3.0 and System 7.5 and later have the }
- { problems in FSpExchangeFiles corrected. }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpOpenResFileCompat ({CONST}VAR spec: FSSpec;
- permission: SignedByte): INTEGER;
- { The FSpOpenResFileCompat function opens the resource file specified }
- { by spec. }
- { }
- { spec input: An FSSpec record specifying the file whose }
- { resource file is to be opened. }
- { permission input: A constant indicating the desired file access }
- { permissions. }
- { function result output: A resource file reference number, or if there's }
- { an error -1. }
-
-
- {***************************************************************************}
-
-
- PROCEDURE FSpCreateResFileCompat ({CONST}VAR spec: FSSpec;
- creator: OSType;
- fileType: OSType;
- scriptTag: ScriptCode);
- { The FSpCreateResFileCompat function creates a new resource file with }
- { the specified type, creator, and script code. }
- { Differences from FSpCreateResFile: FSpCreateResFileCompat correctly }
- { sets the fdScript in the file's FXInfo record to scriptTag if the }
- { problem isn't fixed in the File Manager code. }
- { }
- { spec input: An FSSpec record specifying the resource file to }
- { create. }
- { creator input: The creator of the new file. }
- { fileType input The file type of the new file. }
- { scriptCode input: The code of the script system in which the file }
- { name is to be displayed. }
-
-
- {***************************************************************************}
-
-
- IMPLEMENTATION
-
- END.